﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    public class PulseRateStatusToColorConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Color myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
            SolidColorBrush myBrush = new SolidColorBrush(myColor);
            if (value == null)
            {
                return myBrush;
            }

            PulseRateStatus status = (PulseRateStatus)value;

            switch (status)
            {
                case PulseRateStatus.None:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PulseRateStatus.Low:
                    myColor = (Color)ColorConverter.ConvertFromString("#F58B00");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PulseRateStatus.Normal:
                    myColor = (Color)ColorConverter.ConvertFromString("#11A84D");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                case PulseRateStatus.High:
                    myColor = (Color)ColorConverter.ConvertFromString("#EB1C2A");
                    myBrush = new SolidColorBrush(myColor);
                    return myBrush;
                default:
                    return myBrush;
            }

        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}